/*     */ package com.hp.bon.sgw.dr.config;
/*     */ 
/*     */ import java.util.Map;
/*     */ import java.util.concurrent.ConcurrentHashMap;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ 
/*     */ public class MdrNodeInfo
/*     */ {
/*  10 */   public static final Logger Log = LoggerFactory.getLogger(MdrNodeInfo.class);
/*     */   public String _name;
/*     */   public String _auditMode;
/*     */   public String _duplex;
/*     */   public long _auditTimeout;
/*     */   public long _expTime;
/*     */   public int _queryCnt;
/*     */   public String _localNodeNm;
/*     */   public String _localNodeDrStatus;
/*     */   public String _peerNodeNm;
/*     */   public String _peerNodeDrStatus;
/*  32 */   public Map<String, Integer> _capDrMap = new ConcurrentHashMap();
/*  33 */   public Map<String, String> _capDependentMap = new ConcurrentHashMap();
/*     */ 
/*  35 */   public MdrNodeInfo() { this._name = "";
/*  36 */     this._auditMode = "";
/*  37 */     this._duplex = "";
/*  38 */     this._localNodeNm = "";
/*  39 */     this._localNodeDrStatus = "";
/*  40 */     this._peerNodeNm = "";
/*  41 */     this._peerNodeDrStatus = "";
/*     */   }
/*     */ 
/*     */   public boolean isValid()
/*     */   {
/*  48 */     boolean rc_ = true;
/*  49 */     if ((this._name == null) || (this._name.length() == 0)) {
/*  50 */       Log.warn("_name is empty");
/*  51 */       rc_ = false;
/*     */     }
/*     */ 
/*  54 */     if ((this._auditMode == null) || (this._auditMode.length() == 0)) {
/*  55 */       Log.warn("_auditMode is empty");
/*  56 */       rc_ = false;
/*  57 */     } else if ((!this._auditMode.equals("FOLLOW")) && (!this._auditMode.equals("SYNC"))) {
/*  58 */       Log.warn("invalid _auditMode=[{}], must be {} or {}", new Object[] { this._auditMode, "FOLLOW", 
/*  59 */         "SYNC" });
/*  60 */       rc_ = false;
/*     */     }
/*     */ 
/*  63 */     if ((this._duplex == null) || (this._duplex.length() == 0)) {
/*  64 */       Log.warn("_duplex is empty");
/*  65 */       rc_ = false;
/*  66 */     } else if ((!this._duplex.equals("DUPLEX")) && (!this._duplex.equals("SINGLE"))) {
/*  67 */       Log.warn("invalid _duplex=[{}], must be {} or {}", new Object[] { this._duplex, "DUPLEX", 
/*  68 */         "SINGLE" });
/*  69 */       rc_ = false;
/*     */     }
/*     */ 
/*  72 */     if (this._auditTimeout <= 0L) {
/*  73 */       Log.warn("invalid _auditTimeout={}, must > 0", Long.valueOf(this._auditTimeout));
/*  74 */       rc_ = false;
/*     */     }
/*     */ 
/*  77 */     if (this._expTime <= 0L) {
/*  78 */       Log.warn("invalid _expTime={}, must > 0", Long.valueOf(this._expTime));
/*  79 */       rc_ = false;
/*     */     }
/*     */ 
/*  82 */     if (this._queryCnt <= 0) {
/*  83 */       Log.warn("invalid _queryCnt={}, must > 0", Integer.valueOf(this._queryCnt));
/*  84 */       rc_ = false;
/*     */     }
/*     */ 
/*  87 */     if ((this._localNodeNm == null) || (this._localNodeNm.length() == 0)) {
/*  88 */       Log.warn("_localNodeNm is empty");
/*  89 */       rc_ = false;
/*     */     }
/*     */ 
/*  92 */     if ((this._localNodeDrStatus == null) || (this._localNodeDrStatus.length() == 0)) {
/*  93 */       Log.warn("_localNodeDrStatus is empty");
/*  94 */       rc_ = false;
/*  95 */     } else if ((!this._localNodeDrStatus.equals("MASTER")) && 
/*  96 */       (!this._localNodeDrStatus.equals("SLAVE"))) {
/*  97 */       Log.warn("invalid _localNodeDrStatus=[{}], must be {} or {}", new Object[] { this._localNodeDrStatus, 
/*  98 */         "MASTER", "SLAVE" });
/*  99 */       rc_ = false;
/*     */     }
/*     */ 
/* 102 */     if ((this._peerNodeNm == null) || (this._peerNodeNm.length() == 0)) {
/* 103 */       Log.warn("_peerNodeNm is empty");
/* 104 */       rc_ = false;
/*     */     }
/*     */ 
/* 107 */     if ((this._peerNodeDrStatus == null) || (this._peerNodeDrStatus.length() == 0)) {
/* 108 */       Log.warn("_peerNodeDrStatus is empty");
/* 109 */       rc_ = false;
/* 110 */     } else if ((!this._peerNodeDrStatus.equals("MASTER")) && 
/* 111 */       (!this._peerNodeDrStatus.equals("SLAVE"))) {
/* 112 */       Log.warn("invalid _peerNodeDrStatus=[{}], must be {} or {}", new Object[] { this._peerNodeDrStatus, 
/* 113 */         "MASTER", "SLAVE" });
/* 114 */       rc_ = false;
/*     */     }
/*     */ 
/* 117 */     return rc_;
/*     */   }
/*     */ 
/*     */   public String toString() {
/* 121 */     StringBuilder sb_ = new StringBuilder();
/* 122 */     sb_.append(String.format("contents of MdrNodeInfo @%x :%n", new Object[] { Integer.valueOf(hashCode()) }));
/* 123 */     sb_.append(String.format(" _name=[%s], _auditMode=[%s], _duplex=[%s]%n", new Object[] { this._name, this._auditMode, this._duplex }));
/* 124 */     sb_.append(String.format(" _auditTimeout=%d, _expTime=%d, _queryCnt=%d%n", new Object[] { Long.valueOf(this._auditTimeout), Long.valueOf(this._expTime), Integer.valueOf(this._queryCnt) }));
/* 125 */     sb_.append(String.format(" _localNodeNm=[%s], _localNodeDrStatus=[%s]%n", new Object[] { this._localNodeNm, this._localNodeDrStatus }));
/* 126 */     sb_.append(String.format(" _peerNodeNm=[%s], _peerNodeDrStatus=[%s]%n", new Object[] { this._peerNodeNm, this._peerNodeDrStatus }));
/* 127 */     sb_.append(String.format(" _capDrMap has %d entries%n", new Object[] { Integer.valueOf(this._capDrMap.size()) }));
/* 128 */     int i = 0;
/* 129 */     for (String k : this._capDrMap.keySet()) {
/* 130 */       sb_.append(String.format("  No.%2d : capability=[%s]-->queue=[%s]%n", new Object[] { Integer.valueOf(++i), k, this._capDrMap.get(k) }));
/*     */     }
/* 132 */     sb_.append(String.format(" _capDependentMap has %d entries%n", new Object[] { Integer.valueOf(this._capDependentMap.size()) }));
/* 133 */     i = 0;
/* 134 */     for (String k : this._capDependentMap.keySet()) {
/* 135 */       sb_.append(String.format("  No.%2d : capability=[%s]%n", new Object[] { Integer.valueOf(++i), k }));
/*     */     }
/*     */ 
/* 142 */     return sb_.substring(0);
/*     */   }
/*     */ 
/*     */   public String getLocalStatusAsThisCap()
/*     */   {
/* 147 */     return this._localNodeDrStatus;
/*     */   }
/*     */ 
/*     */   public String getMasterNEHostId()
/*     */   {
/* 156 */     if (this._localNodeDrStatus.equals("MASTER"))
/*     */     {
/* 158 */       return this._localNodeNm;
/*     */     }
/*     */ 
/* 162 */     return this._peerNodeNm;
/*     */   }
/*     */ 
/*     */   public String getSlaveNEHostId()
/*     */   {
/* 167 */     if (this._localNodeDrStatus.equals("SLAVE"))
/*     */     {
/* 169 */       return this._localNodeNm;
/*     */     }
/*     */ 
/* 173 */     return this._peerNodeNm;
/*     */   }
/*     */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.sgw.dr.config.MdrNodeInfo
 * JD-Core Version:    0.6.1
 */